/**
 * @Author: 焦质晔
 * @Date: 2019/6/20
 * @Last Modified by: mikey.zhaopeng
 * @Last Modified time: 2019-08-20 11:45:10
 */
import axios from '@/api/fetch';
import * as types from './types';
import SERVER from '@/api/server';
//项目方案下发大首页数据getList

export const getData = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/getListActive`, { params: _params, menuId: '-1' });

//得到用户基本信息 id=-9999999
// export const getUserBaseInfo = id => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/${id}`);//移到distribution
export const selectPageBySqlActive = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/selectPageBySqlActive`, { params: _params, menuId: '-1' });
//修改基础活动信息+附件信息.
export const updateAll = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/projectProgram/updateAll/${id}`, params);
//项目方案下发大首页数据 修改方案状态
export const updateStatusBy = params => axios.put(`${SERVER.CMSCLOUD_MARKET}/projectProgram`, params);

// 保存活动信息-自定义
export const saveExcercise = (modelId, params) => axios.post(`${SERVER.CMSCLOUD_MARKET}/excercise/saveOne/${modelId}`, params);
// update活动信息
export const updateExcercise = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/projectProgram/updateStatus/${id}`, params);
//得到tm_project_program附件
export const selectListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/getProjectProgramListByBill`, { params });
//新增tm_project_program附件
// export const addProgramProgramURL = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/projectProgram/insert`, params);

//编辑tm_project_program附件
export const updateProgramProgramURL = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/projectProgram/${id}`, params);

// 保存基础活动信息-模板生成
export const saveExcerciseAll = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/projectProgram/insert`, params);
//得到附件,无需xml,也不用权限限制.
export const getInfoBase = id => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/getFileUrlMapById/${id}`); //都用
//物流get数据
export const getMaterial = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getProjectMaterialDealer`, { params });
//物料get数据
export const getInfoGoods = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectMaterial/getProjMaterialList`, { params: _params, menuId: '-1' });
//物流保存数据
export const saveMaterials = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/insert`, params);
//insert into tr_project_material table projectMaterial 注意,post不能加括号!

export const saveProjectMaterial = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/projectMaterial/insertFromMeterail`, params);
//保存事业部 tr_project_org
export const saveProjectOrg = (id, params) => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg/deleteAndInsert/${id}`, params);

//活动方案get
export const getProjectOrg = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg`, { params });
//活动方案insert
export const insertProjectOrg = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg/insert`, params);
//插入projectItemModel表记录
export const insertProjectItemModel = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/projectItemModel/insertFromList`, params);

//  获取所有活动,params中已经默认包含了page信息,只要添加params即可.
// export const getActivityList = params => axios.post(`${SERVER.INFORMATION}/activityInfo/pageQuery`, {  page:params.pageNum, ...params });
//  保存活动信息
// export const saveActivity0 = (modelId,params )=> axios.post(`${SERVER.INFORMATION}/activityInfo/saveFromPc0`, params);
export const saveActivity = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/excercise/insertFromList`, params);
//  delete活动信息
export const fun_EditAll = (id, params) => axios.post(`${SERVER.CMSCLOUD_MARKET}/excercise/deleteByProjectProgramId/${id}`, params);
//  delete物料信息
export const deleteByProjectProgramId = (id, params) => axios.post(`${SERVER.CMSCLOUD_MARKET}/projectMaterial/deleteByProjectProgramId/${id}`, params);
//事业部
export const getShiYeDept = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg`, { params: _params, menuId: '-1' });

//查询物料类型-一级
export const getmaterialTypeOneList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/paramdefinition/marketMaterialType/queryList`, { params });

export const getmaterialTypeName = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/paramdefinition/marketMaterialType/queryName`, { params });
////======事业部
//事业部四表关联
// export const selectOneByProgramId = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/selectOneByProgramId`, { params });//移到distribution
// export const getListProjOrg =  (_params) => axios.get(`${SERVER.CMSCLOUD_MARKET}/projectProgram/getListProjOrg`, {params:_params,menuId:'-1'});//移到distribution中
//insert ProjectOrgDTO
// export const insertProjOrg = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg`, params);//移到distribution
//updateProjectOrgStatus
export const updateProjectOrgStatus = (id, params) => axios.put(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectOrg/updateStatus/${id}`, params);
////====事业部-经销商
//getListById
// export const getListDealer =  params =>  axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer`,params);
// inserts插入多条记录List<ProjectDealerDTO>
// export const insertDealers = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/insertFromList`, params);//移到distribution
//根据projectDealerOBJ删除记录
// export const deleteByDealerObj = id => axios.delete(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/deleteByDealerObj/${id}`);//移到distribution
//delete 批量
export const deleteDealers = params => axios.delete(`${SERVER.CMSCLOUD_MARKET}"/caseManager/projectDealer/batch/${params}`);
//getList根据提供的多个ids得到list
// export const getListByDealer = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/caseManager/projectDealer/getListByDealer`, { params });//移到distribution

//zys 勿动，谢谢
//查询营销素材列表
// export const getMaterialList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialList`, { params });
export const getMaterialList = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialList`, { params: _params, menuId: '-1' });
//查询营销素材列表DLR
export const getMaterialListDLR = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialList/dlr`, { params: _params, menuId: '-1' });

//营销素材数据导出
// export const getMaterialExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/export/excel`, params, { responseType: 'arraybuffer' });
export const getMaterialExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/material/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//营销素材DLR数据导出
export const getMaterialExcelListDLR = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/material/export/excel/dlr`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//营销素材数据导出模板
export const getMaterialExcelDemoList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/export/excelDemo`, params, { responseType: 'arraybuffer' });

//获取营销素材附件
export const selectMaterialListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/getMaterialListByBill`, { params });

//获取营销素材反馈附件
export const selectFeedListByBill = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getFeedListByBill`, { params });

//获取营销素材下发的经销商列表数据
export const getDealers = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getDealers`, { params });

//营销素材编辑
export const updateMaterial = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/material/update/${id}`, params);

//批量提报
export const batchHandAll = ids => axios.put(`${SERVER.CMSCLOUD_MARKET}/material/batchupdate/${ids}`);

//批量停用
export const batchtyAll = ids => axios.put(`${SERVER.CMSCLOUD_MARKET}/material/batchty/${ids}`);

//营销素材导入
export const importMaterialList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/import`, params);

//打开明细获取物料首次查看人信息
export const getIsViewDetail = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getIsViewDetail`, { params });

//获取营销素材信息反馈查询列表
// export const getDealerMaterialPageBySql = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getDealerMaterialPageBySql`, { params });
export const getDealerMaterialPageBySql = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getDealerMaterialPageBySql`, { params: _params, menuId: '-1' });

//获取营销素材信息反馈查询列表OEM
export const getDealerMaterialPageBySqlOEM = _params => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/getDealerMaterialPageBySqlOEM`, { params: _params, menuId: '-1' });

//营销素材信息反馈查询列表导出
// export const getDealMaterialExcelList = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/export/excel`, params, { responseType: 'arraybuffer' });
export const getDealMaterialExcelList = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/export/excel`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};
//营销素材信息反馈查询列表(非事业部)导出
export const getDealMaterialExcelListOEM = params => {
  params = Object.assign(params, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/export/excel/oem`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};

//营销素材信息反馈编辑(自定义update)
export const updateDealerMaterial = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/updateDealerMaterial/${id}`, params);
//营销素材信息反馈编辑(框架update)
export const update = (params, id) => axios.put(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/update/${id}`, params);
//营销素材信息反馈新增
export const saveDealerMaterial = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/saveMaterial`, params);

//营销素材反馈审核日志保存
export const saveLog = params => axios.post(`${SERVER.CMSCLOUD_MARKET}/material/materialReviewLog/saveLog`, params);
//营销素材反馈审核日志查询
export const getList = params => axios.get(`${SERVER.CMSCLOUD_MARKET}/material/materialReviewLog/getList`, { params });

//根据id查询反馈详细信息
export const selectDealerMaterialById = id => axios.get(`${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/${id}`);

//营销素材信息反馈批量下载附件
export const batchDownLoadAll = ids => {
  let params = Object.assign({}, { menuId: '-1' });
  return axios({
    url: `${SERVER.CMSCLOUD_MARKET}/dealermaterial/dealerMaterial/downLoadAll/${ids}`,
    method: 'get',
    params: params,
    responseType: 'blob'
  });
};
// //  删除活动
// export const delActivity = id => axios.post(`${SERVER.INFORMATION}/activityInfo/delete?id=${id}`);
// //  查看报名情况
// export const checkSign = id => axios.get(`${SERVER.INFORMATION}/activitySign/queryActivitySignVOS?activityId=${id}`);
// //  发布活动
// export const publishActivity = id => axios.post(`${SERVER.INFORMATION}/activityInfo/publish?id=${id}`);
// //  下架活动
// export const offActivity = id => axios.post(`${SERVER.INFORMATION}/activityInfo/off?id=${id}`);
// //  停止报名
// export const stopSign = id => axios.post(`${SERVER.INFORMATION}/activityInfo/stopSign?id=${id}`);
// //  获取活动详情
// export const activityDetail = id => axios.get(`${SERVER.INFORMATION}/activityInfo/detail?id=${id}`);
// // 获取车型数据
// export const getAllModal = appId => axios.get(`${SERVER.BASEDATA}/vehicleProduct/open/getAllModel?appId=${appId}`);
